package com.burges.net.dataStream.codeRuler.dataSinks

import org.apache.flink.core.fs.FileSystem.WriteMode
import org.apache.flink.streaming.api.scala.{StreamExecutionEnvironment, _}
import org.apache.flink.streaming.util.serialization.SimpleStringSchema

/**
  * 文件输出
  */
object BasicSink {
  def main(args: Array[String]): Unit = {

    val env = StreamExecutionEnvironment.getExecutionEnvironment

    val personStream = env.fromElements(("Alex", 18), ("Peter", 43))

    //输出到CSV文件
    personStream.writeAsCsv("file:///path/to/person.csv", WriteMode.OVERWRITE)

    //文本文件输出
    personStream.writeAsText("file:///path/to/person.txt")

    // 输出到指定的Socket端口
//    personStream.writeToSocket(outputHost, outputPort, new SimpleStringSchema())
  }
}
